﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DataManager.TablesManager
{
    public class MessManager : Manager
    {
        public bool Update(MESS mess)
        {
            try
            {
                DBDataContext db = new DBDataContext();
                var query =
                    from ord in db.MESSes
                    where ord.MESS_ID == mess.MESS_ID
                    select ord;
                foreach (MESS ord in query)
                {
                    ord.MESS_CONTENT = mess.MESS_CONTENT;
                    ord.MESS_TIME = mess.MESS_TIME;
                    ord.USERID_FORM = mess.USERID_FORM;
                    ord.USERID_TO = mess.USERID_TO;
                    ord.MESS_STATUS = mess.MESS_STATUS;
                }
                db.SubmitChanges();
                return true;
            }
            catch (Exception e)
            {
                Logs.Write(e);
                return false;
            }
        }
    }
}
